package com.tedu.egmybatis1.mapper;

import com.tedu.egmybatis1.pojo.Product;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface UserMapper {
    @Insert("INSERT INTO product(id,title,price,stock) VALUES(#{id},#{title},#{price},#{stock})")
    int insertProduct(Product product);

    @Update("UPDATE product SET title=#{title},price=#{price},stock=#{stock} WHERE id=#{id}")
    int updateProduct(Product product);

    @Delete("DELETE FROM product WHERE id=#{id}")
    int deleteProduct(Integer id);

    @Select("SELECT * FROM product WHERE id=#{id}")
    Product selectProduct(Integer id);

    @Select("SELECT * FROM product")
    List<Product> selectAllProduct();
}
